package com.sinothk.fc.goodsLibrary.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sinothk.fc.goodsLibrary.entity.GoodsLibraryEntity;
import com.sinothk.fc.goodsLibrary.mapper.GoodsLibraryMapper;
import com.sinothk.fc.goodsLibrary.service.IGoodsLibraryService;
import org.springframework.stereotype.Service;

/**
 * @Description: 商品基础信息
 * @Author: Liangyt
 * @Date: 2022-07-27
 * @Version: V1.0
 */
@Service
public class GoodsLibraryServiceImpl extends ServiceImpl<GoodsLibraryMapper, GoodsLibraryEntity> implements IGoodsLibraryService {

    @Override
    public void addOrEdit(GoodsLibraryEntity goodsLibraryEntity) {
        LambdaQueryWrapper<GoodsLibraryEntity> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(GoodsLibraryEntity::getGoodsNo, goodsLibraryEntity.getGoodsNo());
        GoodsLibraryEntity goodsLibraryEntityDB = this.getOne(wrapper);
        if (goodsLibraryEntityDB == null) {
            this.save(goodsLibraryEntity);
        } else {
            goodsLibraryEntity.setId(goodsLibraryEntityDB.getId());
            this.updateById(goodsLibraryEntity);
        }
    }
}
